package com.application.lucky.activity.me;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.application.lucky.R;
import com.application.lucky.bean.jsonBean.RechargeItem;
import com.application.lucky.widget.TitlebarView;
import com.application.mylibrary.base.BaseActivity;
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chad.library.adapter.base.entity.AbstractExpandableItem;
import com.chad.library.adapter.base.entity.MultiItemEntity;

import java.util.ArrayList;
import java.util.List;

public class HelpCenterActivity extends BaseActivity {

    private TitlebarView mTitleBar;
    private RecyclerView mRclView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        initView();
        initListener();
    }

    private void initListener() {
        mTitleBar.setOnViewClick(new TitlebarView.onViewClick() {
            @Override
            public void leftClick() {
                finishAnim();
            }

            @Override
            public void rightClick() {

            }
        });
    }

    @Override
    public void beforeInit() {

    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_help_center;
    }

    private void initView() {
        mTitleBar = (TitlebarView) findViewById(R.id.title_bar);
        mRclView = (RecyclerView) findViewById(R.id.rcl_view);
        mRclView.setLayoutManager(new LinearLayoutManager(this));
        loadData();
        mRclView.setAdapter(new MyAdapter(new ArrayList<MultiItemEntity>()));
    }

    private void loadData() {

    }

    static class MyAdapter extends BaseMultiItemQuickAdapter<MultiItemEntity, BaseViewHolder> {
        public static final int Type_GRoup = 0;
        public static final int Type_Item = 2;

        public MyAdapter(List<MultiItemEntity> data) {
            super(data);
            addItemType(Type_GRoup, R.layout.item_help_group);
            addItemType(Type_Item, R.layout.item_help_item);
        }

        @Override
        protected void convert(BaseViewHolder helper, MultiItemEntity item) {
            if (helper.getItemViewType() == Type_GRoup) {
                helper.setText(R.id.tv_item_help_goup_name, ((HelpBen) item).name);

            } else {
                helper.setText(R.id.tv_item_help_goup_name, ((HelpItemBean) item).name);
            }
        }
    }

    static class HelpItemBean implements MultiItemEntity {
        private int type;

        public HelpItemBean(int type) {
            this.type = type;
        }

        public String name;

        public HelpItemBean() {
        }

        @Override
        public int getItemType() {
            return type;
        }
    }

    static class HelpBen extends AbstractExpandableItem implements MultiItemEntity {
        public String name;

        @Override
        public int getLevel() {
            return MyAdapter.Type_GRoup;
        }

        @Override
        public int getItemType() {
            return MyAdapter.Type_GRoup;
        }
    }
}
